<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        #div {
            width: 100px;
            height: 50px;
            border: 1px solid #000;
        }
    </style>
</head>
<body>
<textarea name="" id="tx" cols="10" rows="5"></textarea>
<button id="btn">发表</button>
<div id="div"></div>
<script>
    //获得html中的三个元素
    var tx = document.querySelector('#tx');
    var btn = document.querySelector('#btn');
    var div = document.querySelector('#div');

    btn.addEventListener('click',function (){
        div.innerHTML = tx.value.replace(/基情|激情/g,'**')
        tx.innerHTML=''
    })

    //定义一个匹配手机号是否正确的正则表达式
    var reg = /^(?:(?:\+|00)86)?1\d{10}$/
    var username = /^[a-zA-Z0-9_-]{2,8}$/
</script>
</body>
</html>